<template>
  <div class="flexbox">
    <!-- 第一步 -->
    <div class="dropdownitem">
      <el-dropdown @command="handleCommand1" trigger="click">
        <el-button type="primary">
          第一步<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="item in list"
            :key="item.id"
            class="item flexbox"
            :command="item.id"
            ><img :src="item.url" alt="" /> {{ item.msg }}</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <div v-if="this.$store.state.answer[0][0] > -1">
        <img :src="list[this.$store.state.answer[0][0]].url" alt="" />{{
          list[this.$store.state.answer[0][0]].msg
        }}
      </div>
    </div>
    <!-- 第二步 -->
    <div class="dropdownitem">
      <el-dropdown @command="handleCommand2" trigger="click">
        <el-button type="primary">
          第二步<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="item in list"
            :key="item.id"
            class="item flexbox"
            :command="item.id"
            ><img :src="item.url" alt="" /> {{ item.msg }}</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <div v-if="this.$store.state.answer[0][1] > -1">
        <img :src="list[this.$store.state.answer[0][1]].url" alt="" />{{
          list[this.$store.state.answer[0][1]].msg
        }}
      </div>
    </div>
    <!-- 第三步 -->
    <div class="dropdownitem">
      <el-dropdown @command="handleCommand3" trigger="click">
        <el-button type="primary">
          第三步<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="item in list"
            :key="item.id"
            class="item flexbox"
            :command="item.id"
            ><img :src="item.url" alt="" /> {{ item.msg }}</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <div v-if="this.$store.state.answer[0][2] > -1">
        <img :src="list[this.$store.state.answer[0][2]].url" alt="" />{{
          list[this.$store.state.answer[0][2]].msg
        }}
      </div>
    </div>
    <!-- 第四步 -->
    <div class="dropdownitem">
      <el-dropdown @command="handleCommand4" trigger="click">
        <el-button type="primary">
          第四步<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            v-for="item in list"
            :key="item.id"
            class="item flexbox"
            :command="item.id"
            ><img :src="item.url" alt="" /> {{ item.msg }}</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <div v-if="this.$store.state.answer[0][3] > -1">
        <img :src="list[this.$store.state.answer[0][3]].url" alt="" />{{
          list[this.$store.state.answer[0][3]].msg
        }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Drag",
  data() {
    return {
      list: [
        {
          id: 0,
          url: require("../assets/img/图片3.png"),
          msg: "根据设计的规则进行列式计算",
        },
        {
          id: 1,
          url: require("../assets/img/图片4.png"),
          msg: "收集与排名相关的信息",
        },
        {
          id: 2,
          url: require("../assets/img/图片5.png"),
          msg: "根据得到的根据结果来对五位同学进行排名结果验证报道",
        },
        {
          id: 3,
          url: require("../assets/img/图片6.png"),
          msg: "析收集到的信息，设计排名的规则",
        },
      ],
    };
  },
  methods: {
    updata() {
      console.log(this.$store.state.pagenum, this.$store.state.answer);
      parent.postMessage(this.$store.state, "*");
    },
    handleCommand1(command) {
      this.$store.state.answer[0][0] = command;
      this.$forceUpdate();
      this.updata();
    },
    handleCommand2(command) {
      this.$store.state.answer[0][1] = command;
      this.$forceUpdate();
      this.updata();
    },
    handleCommand3(command) {
      this.$store.state.answer[0][2] = command;
      this.$forceUpdate();
      this.updata();
    },
    handleCommand4(command) {
      this.$store.state.answer[0][3] = command;
      this.$forceUpdate();
      this.updata();
    },
  },
};
</script>
<style scoped>
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.item {
  width: 200px;
  height: 120px;
  line-height: 25px;
  border: 1px solid #000;
  font-size: 20px;
  margin-right: 10px;
  font-weight: 1000;
}
.item img {
  width: 100px;
  height: 100px;
}
.dropdownitem {
  padding: 10px 0px 0px 10px;
  width: 130px;
  height: 300px;
  border: 1px solid #000;
}
</style>
